#include <iostream>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

int main(){

	int n,m;
	cin >> n >> m;
	int c[n+1] = {0},ans[100005] = {0};
	map<int , set<int>> v;
	int ret = 100005;
	for(int i = 1; i <= n; ++i){
		cin >> c[i];
		ret = min(ret,c[i]);
	}
	for(int i = 1; i <= m; ++i){
		int x,y;
		cin >> x >> y;
		int c1 = c[x];
		int c2 = c[y];
		if(c1 != c2){
			if(!v[c1].count(c2)){
				++ans[c1];
				v[c1].insert(c2);
			}
			if(!v[c2].count(c1)){
				++ans[c2];
				v[c2].insert(c1);
			}
			
			if(ans[ret] < ans[c1]){
				ret = c1;
			}else if(ans[ret] == ans[c1]){
				ret = c1 < ret ? c1 : ret;
			}
			
			if(ans[ret] < ans[c2]){
				ret = c2;
			}else if(ans[ret] == ans[c2]){
				ret = c2 < ret ? c2 : ret;
			}
		}
	}
	
	cout << ret;

	return 0;
}
